import tkinter as tk
from queue import Queue
q = Queue()

def encode(char):
    s = '0x'
    for x in char.encode():
        s = s + str(hex(x))[2:4]
    return int(s,16)

def f(s):
    v = []
    for x in s:
        v.append(encode(x))
    return v

window = tk.Tk()
window.title('中文取模映射')
class App():
    def __init__(self,window):
        self.window = window
        self.creat()
        self.pack()
    def creat(self):
        self.t1 = tk.Text(window,height = 5,width = 60)
        self.t2 = tk.Text(window,height = 5,width = 60)
        self.t3 = tk.Text(window,height = 9,width = 60)
        self.b = tk.Button(window,command = self.call, text = '开始取模',height = 2,width = 9)
    def pack(self):
        self.t1.pack()
        self.t2.pack()
        self.t3.pack()
        self.b.pack()
    def call(self):
        x = 'q.put(fonts)'
        var1 = self.t1.get('0.0','end')
        var2 = self.t2.get('0.0','end')
        var2 = var2+x
        exec(var2)
        fonts = q.get()
        c = zip(f(var1),fonts)
        self.t3.insert('0.0',str(dict(c)))
App(window)
window.mainloop()
